home *** CD-ROM | disk | FTP | other *** search
/ IRIS Performer 2.2 Friends Demo / SGI IRIS Performer 2.2 Friends Demo.iso / friends / technology_playgroup / unwinder / driver_api / uwbasic.h < prev   
C/C++ Source or Header  |  1997-11-17  |  3KB  |  106 lines

  1. /**********************************************************************
  2.  * TECHNOLOGY PLAYGROUP INC.   http://this.is/tpg   email: tpg@this.is
  3.  **********************************************************************
  4.  *
  5.  *    FILE: uwbasic.h
  6.  *
  7.  * VERSION: 1.0
  8.  *    DATE: 17 nov 1997
  9.  *
  10.  * A simple interface API for the UNWINDER dual joystick adapter v2.1
  11.  *
  12.  *
  13.  * This program is intended as a starting point for communicating
  14.  * with the UNWINDER, and not considered a finished product.
  15.  *
  16.  * see notes with uwbasic.c
  17.  *
  18.  *
  19.  **********************************************************************
  20.  * Glenn Silver [Nov97] TPG            -  current implementation 
  21.  * Jonathan Franco [Aug97] InfoMediArt -  1st design & implementation  
  22.  **********************************************************************/
  23.  
  24.  
  25. #ifndef __UWBASIC_H__
  26. #define __UWBASIC_H__
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif 
  30.  
  31.  
  32. #include <stdio.h> 
  33.  
  34.  
  35.   /* UNWINDER joystick data structure */
  36. typedef struct {
  37.   unsigned short x;        /* X stick axis (left/down)              */
  38.   unsigned short y;        /* Y stick axis (up/down)                */
  39.   unsigned short z;        /* Z stick axis (rotation)               */
  40.   unsigned short t;        /* T stick axis (slider)                 */
  41.   unsigned char buttons;   /* all buttons switch status             */
  42.   unsigned char hat;       /* hat position                          */
  43.   unsigned char sw;        /* switch on or off (digital mode only)  */
  44. } uwJoystick;
  45.   
  46.  
  47. /* Button position flag */
  48. #define uwBUTTON_B1 (01<<0)
  49. #define uwBUTTON_B2 (01<<1)
  50. #define uwBUTTON_B3 (01<<2)
  51. #define uwBUTTON_B4 (01<<3)
  52. #define uwBUTTON_B5 (01<<4)
  53. #define uwBUTTON_B6 (01<<5)
  54. #define uwBUTTON_B7 (01<<6)
  55. #define uwBUTTON_B8 (01<<7)
  56. #define uwBUTTON_TRIGGER         uwBUTTON_B1 
  57. #define uwBUTTON_FRONT           uwBUTTON_B2
  58. #define uwBUTTON_SIDE_UP         uwBUTTON_B3
  59. #define uwBUTTON_SIDE_DOWN       uwBUTTON_B4
  60. #define uwBUTTON_BASE_LEFT_UP    uwBUTTON_B5
  61. #define uwBUTTON_BASE_RIGHT_UP   uwBUTTON_B6
  62. #define uwBUTTON_BASE_RIGHT_DOWN uwBUTTON_B7
  63. #define uwBUTTON_BASE_LEFT_DOWN  uwBUTTON_B8
  64.  
  65. /* Hat position flag */
  66. #define uwHAT_REST       0
  67. #define uwHAT_UP         1
  68. #define uwHAT_UP_RIGHT   2
  69. #define uwHAT_RIGHT      3
  70. #define uwHAT_DOWN_RIGHT 4
  71. #define uwHAT_DOWN       5
  72. #define uwHAT_DOWN_LEFT  6
  73. #define uwHAT_LEFT       7
  74. #define uwHAT_UP_LEFT    8
  75.  
  76. /* Low level function */ 
  77. void uwSendCommands(char *commands);
  78. int uwPollData(char mode, char* data, int byteNb); 
  79. void uwFlush(void);
  80. void uwProcessData(char* data, uwJoystick* joy);
  81.  
  82. /* Initialize and trace command */
  83. int uwOpenPort(char *devicePort, char *initCmd);
  84. void uwClosePort(void);
  85. void uwSetVerbose(int val);
  86. void uwPrint(FILE* fp, uwJoystick* j);
  87.  
  88. /* Joystick polling */ 
  89. int uwPoll1(uwJoystick* joystick);
  90. int uwPoll2(uwJoystick* joystick);
  91. int uwPoll12(uwJoystick* joystick1, uwJoystick* joystick2);
  92.  
  93.  
  94.  
  95. /* Note: 
  96.    - Every functions with a return value, except uwPollData,
  97.      return 1 (success) or 0 (fail).
  98.    - uwPollData return the number of bytes read or -1 if failed
  99. */
  100.  
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif /* #ifdef __UWBASIC */
  105.  
  106.